#ifndef _SB3D_CONVAR_H_
#define _SB3D_CONVAR_H_

#include "Common.h"
#include <iostream>


typedef enum
{
	CVAR_ARCHIVE	= BIT(0),	// set to cause it to be saved to config.cfg
	CVAR_USERINFO	= BIT(1),	// added to userinfo  when changed
	CVAR_SERVERNOTIFY	= BIT(2),	// notifies players when changed
	CVAR_EXTDLL	= BIT(3),	// defined by external DLL
	CVAR_CLIENTDLL	= BIT(4),	// defined by the client dll
	CVAR_PROTECTED	= BIT(5),	// it's a server cvar, but we don't send the data since it's a password, etc.
	CVAR_SPONLY	= BIT(6),	// this cvar cannot be changed by clients connected to a multiplayer server.
	CVAR_PRINTABLEONLY	= BIT(7),	// this cvar's string cannot contain unprintable characters ( player name )
	CVAR_UNLOGGED	= BIT(8),	// if this is a FCVAR_SERVER, don't log changes to the log file / console
	CVAR_SERVERINFO	= BIT(9),	// added to serverinfo when changed
	CVAR_PHYSICINFO	= BIT(10),// added to physinfo when changed
	CVAR_RENDERINFO	= BIT(11),// save to a seperate config called opengl.cfg
	CVAR_CHEAT	= BIT(12),// can not be changed if cheats are disabled
	CVAR_INIT		= BIT(13),// don't allow change from console at all, but can be set from the command line
	CVAR_LATCH	= BIT(14),// save changes until server restart
	CVAR_READ_ONLY	= BIT(15),// display only, cannot be set by user at all
	CVAR_LATCH_VIDEO	= BIT(16),// save changes until render restart
	CVAR_USER_CREATED	= BIT(17),// created by a set command (dll's used)
	CVAR_GLCONFIG	= BIT(18),// set to cause it to be saved to opengl.cfg
} ConVar_Flags;

class sb3dConVar
{
public:
	std::string name;
	std::string data;
	int flags;
	float value;
	int integer;
	sb3dConVar *next;
	
	std::string description;
	
};

class sb3dConVars
{
public:
	sb3dConVars();
	virtual ~sb3dConVars();
	
	sb3dConVar* FindVar(std::string szName);
	sb3dConVar* GetVar( std::string var_name, std::string var_value, int flags, std::string var_desc );
	
private:
	sb3dConVar *pFirst;
	


};

extern sb3dConVars	*cvars;

// Utilities
int Q_atoi( const char *str );
float Q_atof( const char *str );

#endif